package org.cheetah.core;

import java.util.List;

import javax.xml.bind.annotation.XmlAccessOrder;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorOrder;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "service-context")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
public class ServiceContextDefinition {
	@XmlElementRef
	private List<ServiceDefinition> services;

	public ServiceContextDefinition register() throws Exception {
		if (services != null) {
			for (ServiceDefinition def : services) {
				def.register();
			}
		}

		return this;
	}

	public void start() throws Exception {
		if (services != null) {
			for (ServiceDefinition def : services) {
				def.start();
			}
		}
	}
}
